(function(app){
	app
	.controller("content_50_checkCtrl",["$scope","$state","myFactory","$http","$stateParams","$state","$q","$ionicHistory",function($scope,$state,myFactory,$http,$stateParams,$state,$q,$ionicHistory){
		
		//接收参数
		var itemId = $stateParams.changeTypeId;//变更项目ID
		var chdrnum01 =  $stateParams.chdrnum01; //保单号
		var chdrcoy = $stateParams.chdrcoy; //保单公司号码
		var searchParam = $stateParams.searchParam;
		var policyData;//保单详情
		var state = $stateParams.state;//跳转路由
		var item50 = $stateParams.item50;//获取信息对象
		$scope.item50 = item50;  //绑定信息对象
		$scope.showFlag = true; //控制前端是否显示“详情、重审、退出”三个功能	
		$scope.chdrnum01=$stateParams.chdrnum01; //保单号		
		var receiveType=item50.receiveType;
			
		//绑定参数到页面
		$scope.chdrnum01 = $stateParams.chdrnum01;
			$scope.data = {
			},
			//重新受理
			/*$scope.renew = function(){
				$.confirm("是否重新受理该保单？", "", function() {
					console.log($scope.checkFlag);
					alert('确认');
				}, function() {
					alert('取消');
				});
			}*/	
			//重新受理
			$scope.renew = function(){
				myFactory.renew();
			}
			//退出移动保全
			$scope.exit = function(){
				myFactory.exit();
			}

			//返回上一页
			$scope.goback = function(){
				myFactory.goBack();
			}
			
			//保单详情弹框
			$scope.showPolicyDetail = function(){
				modal('open','policyModalOn50_check_Input','overwindowOn50_check_Input','policyCloseXOn50_check_Input');
				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//初始化时候查询保单详情
				$http({
					method: 'GET',
					url: app.domain + 'query/restFindPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data;
						$scope.policyData = policyData;//绑定至页面
						$scope.policyData.ptdate01=myFactory.DateTools($scope.policyData.ptdate01);
					}
				}, function errorCallback(response) {
					myFactory.alert("","初始化查询订单详情失败!","info");
				});
			}
			//保单详情弹窗关闭函数
			$scope.policyModalOn50_check_Input = function(){
				modal('close','policyModalOn50_check_Input','overwindowOn50_check_Input','policyCloseXOn50_check_Input');
			}
			
			//关闭遮罩
			$scope.overwindowClose = function(){
				$(".overwindow").hide();
				$(".overmodal").hide();
			}	
			
			//根据路由判断是否要显示详情、重新受理、退出三个功能
			if("history_detail"==state){
				$scope.showFlag = false;//不显示
			}			

		}]);
	
	//指针弹窗
	app.directive('infoid',function(){
		return {
			restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
			templateUrl: 'html/input/content_base_info.html'+app.clearCache,
			replace: true,		//设置解析后，DOM声明的指令是否消失
			link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
				console.log('指令完成');
			}
		}
	});	
	
	
	
	
})(app)